#include <iostream>
using namespace std;
typedef long long LL;

const int N = 1e5 + 10;
LL Sum[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, q;
    LL sum = 0;
    cin >> n >> q;
    for (int i = 1; i <= n; ++i)
    {
        int a;
        cin >> a;
        Sum[i] = sum += a;
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << Sum[r] - Sum[l - 1] << endl;
    }
    return 0;
}